#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 2e5+10;

typedef long long ll;

int a[MAXN],n,tot;
ll ans,val[MAXN<<2],sum[MAXN<<2];

struct line{
	int x1,x2,y,tag;
	bool operator < (const line &b)const{
		return y < b.y;
	}
}l[MAXN];

void pushup(int o,int l,int r){
	if(sum[o]) val[o] = a[r+1] - a[l];
	else if(l == r) val[o] = 0;
	else val[o] = val[o<<1] + val[o<<1|1];
}

void update(int xl,int xr,int v,int o = 1,int l = 1,int r = tot-1){
	if(l == xl &&  r == xr) {
		sum[o] += v;
		pushup(o,l,r);
		return;
	}
	int mid = l+r>>1;
	if(xr <= mid) update(xl,xr,v,o<<1,l,mid);
	else if(xl > mid) update(xl,xr,v,o<<1|1,mid+1,r);
	else update(xl,mid,v,o<<1,l,mid),update(mid+1,xr,v,o<<1|1,mid+1,r);
	pushup(o,l,r);
}

int main (){
	scanf("%d",&n);
	for(int i = 1;i <= n;i++){
		int x1,y1,x2,y2;
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		l[(i<<1)-1]  =(line){x1,x2,y1,1};
		l[i<<1] = (line){x1,x2,y2,-1};
		a[(i<<1)-1] = x1;
		a[i<<1] = x2;
	}
	n<<=1;
	sort(a+1,a+n+1);
	sort(l+1,l+n+1);
	tot = unique(a+1,a+n+1)-a-1;
	for(int i = 1;i < n;i++){
		l[i].x1 = lower_bound(a+1,a+tot+1,l[i].x1) - a;
		l[i].x2 = lower_bound(a+1,a+tot+1,l[i].x2) - a;
		if(l[i].x1 != l[i].x2) update(l[i].x1,l[i].x2-1,l[i].tag);
		ans += val[1] * (l[i+1].y - l[i].y);
	}
	printf("%lld\n",ans);
	return 0;
}
